package com.ruoyi.business.enums;

import java.util.Arrays;
import java.util.Optional;

public enum RefundState {
    SUCCESS("SUCCESS","退款成功") ,
    CLOSED("CLOSED","退款关闭") ,
    ABNORMAL("ABNORMAL","退款异常") ;
    private String code ;
    private String desc ;

    RefundState(String code, String desc){
        this.code = code ;
        this.desc = desc ;
    }

    public static boolean checkExist(String code){

        Optional<RefundState> dealOp = Arrays.stream(RefundState.values()).filter(deal -> deal.code == code).findFirst() ;
        return dealOp.isPresent() ;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDescByCode(String code){
        Optional<RefundState> dealOp = Arrays.stream(RefundState.values()).filter(deal -> deal.code.equals(code)).findFirst() ;
        return dealOp.get().desc ;
    }
}
